home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / DESK / CORE / Desk / h_doc / GFX < prev    next >
Text File  |  1996-05-21  |  8KB  |  234 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    GFX.gfx.h
  12.     Author:  Copyright © 1992, 1993 Edouard Poor, Jason Williams, Jason Howat
  13.     Version: 0.71 (02 Sep 1995)
  14.     Purpose: Graphics manipulation commands
  15.     Mods:    02 Sep 1995 JH Added Desk_GFX_Mode, Desk_GFX_SetOrigin.
  16. */
  17.  
  18.  
  19. #ifndef __Desk_GFX_h
  20. #define __Desk_GFX_h
  21.  
  22. #ifdef __cplusplus
  23.     extern "C" {
  24. #endif
  25.  
  26.  
  27. /* Plot codes to be used with the Desk_GFX_Plot function. */
  28.  
  29. #define  Desk_plot_SOLIDBOTH       0x00
  30. #define  Desk_plot_SOLIDEXFINAL    0x08
  31. #define  Desk_plot_DOTTEDBOTH      0x10
  32. #define  Desk_plot_DOTTEDEXFINAL   0x18
  33. #define  Desk_plot_SOLIDEXINIT     0x20
  34. #define  Desk_plot_SOLIDEXBOTH     0x28
  35. #define  Desk_plot_DOTTEDEXINIT    0x30
  36. #define  Desk_plot_DOTTEDEXBOTH    0x38
  37. #define  Desk_plot_POINT           0x40
  38. #define  Desk_plot_HHORZLINEFILLNB 0x48
  39. #define  Desk_plot_TRIANGLEFILL    0x50
  40. #define  Desk_plot_HORIZLINEFILLB  0x58
  41. #define  Desk_plot_RECTANGLEFILL   0x60
  42. #define  Desk_plot_HORIZLINEFILLF  0x68
  43. #define  Desk_plot_PARALLELFILL    0x70
  44. #define  Desk_plot_HORIZLINEFILLNF 0x78
  45. #define  Desk_plot_FLOODTOBACK     0x80
  46. #define  Desk_plot_FLOODTOFORE     0x88
  47. #define  Desk_plot_CIRCLE          0x90
  48. #define  Desk_plot_CIRCLEFILL      0x98
  49. #define  Desk_plot_CIRCLEARC       0xA0
  50. #define  Desk_plot_SEGMENT         0xA8
  51. #define  Desk_plot_SECTOR          0xB0
  52. #define  Desk_plot_BLOCK           0xB8
  53. #define  Desk_plot_ELLIPSE         0xC0
  54. #define  Desk_plot_ELLIPSEFILL     0xC8
  55. #define  Desk_plot_GRAPHICSCHAR    0xD0
  56. #define  Desk_plot_SPRITE          0xE8
  57.  
  58. /* Within each block of eight the offset from the base number means: */
  59. #define  Desk_plot_MOVECURSORREL   0
  60. #define  Desk_plot_DRAWRELFORE     1
  61. #define  Desk_plot_DRAWRELINVERSE  2
  62. #define  Desk_plot_DRAWRELBACK     3
  63. #define  Desk_plot_MOVECURSORABS   4
  64. #define  Desk_plot_DRAWABSFORE     5
  65. #define  Desk_plot_DRAWABSINVERSE  6
  66. #define  Desk_plot_DRAWABSBACK     7
  67.  
  68.  
  69. /* The above applies except for Desk_plot_BLOCK where the codes are as follows: */
  70. #define  Desk_plot_BMOVEREL        0
  71. #define  Desk_plot_BMOVERECTREL    1
  72. #define  Desk_plot_BCOPYRECTREL    2
  73.  
  74. #define  Desk_plot_BMOVEABS        4
  75. #define  Desk_plot_BMOVERECTABS    5
  76. #define  Desk_plot_BCOPYRECTABS    6
  77.  
  78.  
  79. enum    {
  80.     Desk_gfx_action_OVERWRITE    = 0,
  81.     Desk_gfx_action_OR,
  82.     Desk_gfx_action_AND,
  83.     Desk_gfx_action_XOR,
  84.     Desk_gfx_action_INVERT,
  85.     Desk_gfx_action_LEAVE,
  86.     Desk_gfx_action_ANDNOT,
  87.     Desk_gfx_action_ORNOT,
  88.     
  89.     Desk_gfx_action_TRANSPARENTBACKGROUND    = 8,
  90.     
  91.     Desk_gfx_action_COLOURPATTERN_1        = 16,
  92.     Desk_gfx_action_COLOURPATTERN_2        = 32,
  93.     Desk_gfx_action_COLOURPATTERN_3        = 48,
  94.     Desk_gfx_action_COLOURPATTERN_4        = 64,
  95.     Desk_gfx_action_COLOURPATTERN_GIANT        = 80
  96.     };
  97. /*
  98. Graphics plot actions. Use with Desk_GFX_GCOL and Desk_ColourTrans_SetGCOL.
  99. See PRM 1-566.
  100.  */
  101.  
  102. extern void Desk_GFX_Plot(int plotcode, int x, int y);
  103. /*
  104.  *    Executes one Desk_OS_Plot command.
  105.  *      plotcode is the Plot code (as above)
  106.  *      x and y are the X and Y screen coordinates to use
  107.  */
  108.  
  109.  
  110.  
  111. /*  Desk_GFX_ miscellaneous drawing macros ------------------------------
  112.  *
  113.  *  Below are some macros using Desk_GFX_Plot to make life easier for you.
  114.  *  the "By" form (MoveBy, etc) moves/draws relative to the current cursor
  115.  *  position, while the other form draws in absolute OS coords.
  116.  *
  117.  *  Desk_GFX_Move(X, Y)  Moves the graphics cursor to the OS co-ordinates X, Y
  118.  *  Desk_GFX_Plot(X, Y)  Plots a pixel at the specified position
  119.  *  Desk_GFX_Draw(X, Y)  Draws a line from the current cursor position to x, y
  120.  */
  121.  
  122. #define Desk_GFX_Move(x, y) Desk_GFX_Plot(Desk_plot_SOLIDBOTH + Desk_plot_MOVECURSORABS, x, y)
  123. #define Desk_GFX_MoveBy(x, y) Desk_GFX_Plot(Desk_plot_SOLIDBOTH + Desk_plot_MOVECURSORREL, x, y)
  124. #define Desk_GFX_PlotPoint(x, y) Desk_GFX_Plot(Desk_plot_POINT + Desk_plot_DRAWABSFORE, x, y)
  125. #define Desk_GFX_PlotPointBy(x, y) Desk_GFX_Plot(Desk_plot_POINT + Desk_plot_DRAWRELFORE, x, y)
  126. #define Desk_GFX_Draw(x, y) Desk_GFX_Plot(Desk_plot_SOLIDBOTH + Desk_plot_DRAWABSFORE, x, y)
  127. #define Desk_GFX_DrawBy(x, y) Desk_GFX_Plot(Desk_plot_SOLIDBOTH + Desk_plot_DRAWRELFORE, x, y)
  128.  
  129.  
  130. extern void Desk_GFX_Rectangle(int x, int y, int w, int h);
  131. /*
  132. Draws a rectangle outline
  133. */
  134.  
  135. #define Desk_GFX_RectangleFill(x, y, w, h)                       \
  136.   {                                                         \
  137.     Desk_GFX_Move(x, y);                                         \
  138.     Desk_GFX_Plot(Desk_plot_RECTANGLEFILL + Desk_plot_DRAWRELFORE, w, h);  \
  139.   }
  140. /*
  141. Draws a filled rectangle
  142. */
  143.  
  144. #define Desk_GFX_Circle(x, y, r)                                 \
  145.   {                                                         \
  146.     Desk_GFX_Move(x, y);                                         \
  147.     Desk_GFX_Plot(Desk_plot_CIRCLE + Desk_plot_DRAWRELFORE, (r), 0);       \
  148.   }
  149. /*
  150. Draw circle outline
  151. */
  152.  
  153. #define Desk_GFX_CircleFill(x, y, r)                             \
  154.   {                                                         \
  155.     Desk_GFX_Move(x, y);                                         \
  156.     Desk_GFX_Plot(Desk_plot_CIRCLEFILL + Desk_plot_DRAWRELFORE, (r), 0);   \
  157.   }
  158. /*
  159. Draw filled circle
  160. */
  161.  
  162.  
  163. extern void Desk_GFX_CLG(void);
  164. /*
  165.  *    Clears the current graphics window to the current background colour
  166.  */
  167.  
  168.  
  169. extern void Desk_GFX_VDU(char ch);
  170. /*    (An Desk_OS_WriteC veneer)
  171.  *    Writes the given ASCII character to the VDU stream
  172.  *    A macro is defined to allow use of the form VDU() as well as Desk_GFX_VDU()
  173.  */
  174.  
  175. #define VDU(C) Desk_GFX_VDU(C)
  176.  
  177.  
  178. #define Desk_GFX_GCOL(A, C) {Desk_GFX_VDU(18); Desk_GFX_VDU(A); Desk_GFX_VDU(C);}
  179. /*    Sets graphics colour and action.
  180.  *    A macro which emits a VDU sequence to change graphics colours
  181.  */
  182.  
  183.  
  184. #define Desk_GFX_Mode(M) {Desk_GFX_VDU(22); Desk_GFX_VDU(M);}
  185. /*
  186.  *    Sets screen mode.
  187.  */
  188.  
  189.  
  190. #define Desk_GFX_SetOrigin(x, y) {short a=(x), b=(y); Desk_GFX_VDU(29); \
  191.                             Desk_GFX_VDU(a & 0xff); Desk_GFX_VDU((a>>8) & 0xff); \
  192.                             Desk_GFX_VDU(b & 0xff); Desk_GFX_VDU((b>>8) & 0xff);}
  193. /*
  194.  *    Sets the graphics origin.
  195.  */
  196.  
  197.  
  198. extern void Desk_GFX_Write0( const char *string);
  199. /*
  200.  *    Writes the given zero-terminated string to the VDU stream
  201.  *    (veneer for SWI "Desk_OS_Write0")
  202.  */
  203.  
  204.  
  205. extern void Desk_GFX_WriteN( const char *string, int numchars);
  206. /*
  207.  *    Writes 'numchars' characters from the given string to the VDU stream
  208.  *    (veneer for SWI "Desk_OS_WriteN")
  209.  */
  210.  
  211.  
  212. extern void Desk_GFX_Wait(void);
  213. /*
  214.  *  [equivalent to WAIT, *FX 19, Desk_OS_Byte 19]
  215.  *
  216.  *    This call does not return until the vertical refresh has finished.
  217.  *    This means that you get control back after the hardware has
  218.  *    finshed updating the screen so if you do any drawing immediately
  219.  *    after this call it will be done while the screen is not being
  220.  *    drawn. This helps reduce flicker. Calling this procedure in Wimp
  221.  *    applications should be only used sparingly as overuse will slow down
  222.  *    screen output to an unacceptable level. Generally only use by
  223.  *    experimentation--write your graphics code, if it flickers too much try
  224.  *    putting in a Desk_GFX_Wait() and see if it help. If it does and the update
  225.  *    speed isn't adversly affected then leave it in.
  226.  */
  227.  
  228. #ifdef __cplusplus
  229. }
  230. #endif
  231.  
  232.  
  233. #endif
  234.